package com.cover;

import com.cover.pojo.Car;
import com.cover.pojo.Radar;
import com.google.gson.Gson;
import org.apache.log4j.Logger;
import org.apache.log4j.helpers.Loader;
import redis.clients.jedis.Jedis;

import javax.lang.model.type.IntersectionType;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.sql.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

public class Main {
    private static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
    private static final String DB_URL = "jdbc:mysql://3.1.2.114:13306/cloudeagle"; // 替换your_database_name为真实数据库名
    private static final String USER = "root";
    private static final String PASSWORD = "TYbyjcsfz@2021";
    // JC-07内侧摄像机1
    // JC-07外侧摄像机2
    // JC-05外侧摄像机1
    // JC-05内侧摄像机2
    // JC-03太成匝道门架摄像机
    // JC-08花莞门架摄像机
    // JC-01门架快车道摄像机1
    // JC-01门架慢车道摄像机2
    // JC-06摄像机
    // 雨棚摄像枪-X102前
    // 雨棚摄像枪-X104前
    // 雨棚摄像枪-X106前
    // 雨棚摄像枪-X112
    // 雨棚摄像枪-X114
    // 雨棚摄像枪-X108
    // 雨棚摄像枪-X110

    public static void main(String[] args) {
        Loader.getResource("log4j.properties");
//        BasicConfigurator.configure();
        Logger logger = Logger.getLogger(Main.class);
        // hashMap1 摄像枪名称和对应雷达ip的关系
        HashMap<String, String> hashMap1 = getStringStringHashMap();
        // hashMap2 摄像枪名称和对应雷达车道的关系
        HashMap<String, int[]> hashMap2 = getStringIntArrayHashMap();
        // hashMap3 摄像枪名称和对应状态的关系
        HashMap<String, Boolean> hashMap3 = getStringBooleanHashMap();
        HashSet<String> hashSet = new HashSet<>();
        Gson gson = new Gson();

        Thread thread1_61_1 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("JC-07外侧摄像机2")) {
                    String url = hashMap1.get("JC-07外侧摄像机2");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("JC-07外侧摄像机2")[0] || radar.getLane() == hashMap2.get("JC-07外侧摄像机2")[1]) {
                                Car car = newCar(radar, "37");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.61,jc07获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_61_1.start(); // 启动线程1_61_1
        Thread thread1_61_2 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("JC-07内侧摄像机1")) {
                    String url = hashMap1.get("JC-07内侧摄像机1");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("JC-07内侧摄像机1")[0] || radar.getLane() == hashMap2.get("JC-07内侧摄像机1")[1]) {
                                Car car = newCar(radar, "36");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.61,jc07获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_61_2.start(); // 启动线程1_61_2
        Thread thread1_62_1 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("JC-05外侧摄像机1")) {
                    String url = hashMap1.get("JC-05外侧摄像机1");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("JC-05外侧摄像机1")[0] || radar.getLane() == hashMap2.get("JC-05外侧摄像机1")[1]) {
                                Car car = newCar(radar, "34");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.62,jc05获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_62_1.start(); // 启动线程1_62_1
        Thread thread1_62_2 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("JC-05内侧摄像机2")) {
                    String url = hashMap1.get("JC-05内侧摄像机2");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("JC-05内侧摄像机2")[0] || radar.getLane() == hashMap2.get("JC-05内侧摄像机2")[1]) {
                                Car car = newCar(radar, "35");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.62,jc05获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_62_2.start(); // 启动线程1_62_2
        Thread thread1_63 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("JC-03太成匝道门架摄像机")) {
                    String url = hashMap1.get("JC-03太成匝道门架摄像机");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("JC-03太成匝道门架摄像机")[0] || radar.getLane() == hashMap2.get("JC-03太成匝道门架摄像机")[1]) {
                                Car car = newCar(radar, "6");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.63,jc03获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_63.start(); // 启动线程1_63
        Thread thread1_64 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("JC-08花莞门架摄像机")) {
                    String url = hashMap1.get("JC-08花莞门架摄像机");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("JC-08花莞门架摄像机")[0] || radar.getLane() == hashMap2.get("JC-08花莞门架摄像机")[1]) {
                                Car car = newCar(radar, "5");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.64,jc08获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_64.start(); // 启动线程1_64
        Thread thread1_65_1 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("JC-01门架快车道摄像机1")) {
                    String url = hashMap1.get("JC-01门架快车道摄像机1");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("JC-01门架快车道摄像机1")[0] || radar.getLane() == hashMap2.get("JC-01门架快车道摄像机1")[1]) {
                                Car car = newCar(radar, "7");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.65,jc01获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_65_1.start(); // 启动线程1_65_1
        Thread thread1_65_2 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("JC-01门架慢车道摄像机2")) {
                    String url = hashMap1.get("JC-01门架慢车道摄像机2");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("JC-01门架慢车道摄像机2")[0] || radar.getLane() == hashMap2.get("JC-01门架慢车道摄像机2")[1]) {
                                Car car = newCar(radar, "8");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.65,jc01获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_65_2.start(); // 启动线程1_65_2
        Thread thread1_68 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("JC-06摄像机")) {
                    String url = hashMap1.get("JC-06摄像机");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("JC-06摄像机")[0] || radar.getLane() == hashMap2.get("JC-06摄像机")[1]) {
                                Car car = newCar(radar, "25");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.68,jc06获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_68.start(); // 启动线程1_68
        Thread thread1_69_1 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("雨棚摄像枪-X106前")) {
                    String url = hashMap1.get("雨棚摄像枪-X106前");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("雨棚摄像枪-X106前")[0] || radar.getLane() == hashMap2.get("雨棚摄像枪-X106前")[1]) {
                                Car car = newCar(radar, "11");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.69,jc11获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_69_1.start(); // 启动线程1_69_1
        Thread thread1_69_2 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("雨棚摄像枪-X104前")) {
                    String url = hashMap1.get("雨棚摄像枪-X104前");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("雨棚摄像枪-X104前")[0] || radar.getLane() == hashMap2.get("雨棚摄像枪-X104前")[1]) {
                                Car car = newCar(radar, "10");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.69,jc11获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_69_2.start(); // 启动线程1_69_2
        Thread thread1_69_3 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("雨棚摄像枪-X102前")) {
                    String url = hashMap1.get("雨棚摄像枪-X102前");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("雨棚摄像枪-X102前")[0] || radar.getLane() == hashMap2.get("雨棚摄像枪-X102前")[1]) {
                                Car car = newCar(radar, "9");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.69,jc11获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_69_3.start(); // 启动线程1_72_1
        Thread thread1_72_1 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("雨棚摄像枪-X114")) {
                    String url = hashMap1.get("雨棚摄像枪-X114");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("雨棚摄像枪-X114")[0] || radar.getLane() == hashMap2.get("雨棚摄像枪-X114")[1]) {
                                Car car = newCar(radar, "15");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.72,jc13获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_72_1.start(); // 启动线程1_72_2
        Thread thread1_72_2 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("雨棚摄像枪-X112")) {
                    String url = hashMap1.get("雨棚摄像枪-X112");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("雨棚摄像枪-X112")[0] || radar.getLane() == hashMap2.get("雨棚摄像枪-X112")[1]) {
                                Car car = newCar(radar, "14");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.72,jc13获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_72_2.start(); // 启动线程1_72_3
        Thread thread1_73_1 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("雨棚摄像枪-X110")) {
                    String url = hashMap1.get("雨棚摄像枪-X110");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("雨棚摄像枪-X110")[0] || radar.getLane() == hashMap2.get("雨棚摄像枪-X110")[1]) {
                                Car car = newCar(radar, "13");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.73,jc14获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_73_1.start(); // 启动线程1_73_1
        Thread thread1_73_2 = new Thread(() -> {
            while (true) {
                if (!hashMap3.get("雨棚摄像枪-X108")) {
                    String url = hashMap1.get("雨棚摄像枪-X108");
                    int port = 1500;
                    try (Socket radarSocket = new Socket(url, port)) {
                        byte[] recv = new byte[6844];
                        radarSocket.getInputStream().read(recv);
                        int start = 0;
                        start += 4;
                        int length = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 2;
                        start += 2;
                        start += 20;
                        start += 8;
                        for (int i = 0; i < length; i++) {
                            Radar radar = new Radar();
                            radar.setSecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setMillisecond(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setId(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setRoad(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjClass(String.valueOf(recv[start]));
                            start += 1;
                            radar.setObjLength(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjWidth(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setOrientationAngle(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setX(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setY(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setxSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setySpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaXSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setaYSpeed(ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort());
                            start += 2;
                            radar.setObjectRCS(0);
                            start += 2;
                            radar.setLongitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLatitude(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setEvent(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;
                            radar.setLane(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getInt());
                            start += 4;

                            start += 4;
                            radar.setObjectLatitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 4;
                            radar.setObjectLongitude(BigDecimal.valueOf(ByteBuffer.wrap(recv, start, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat()));
                            start += 8;
                            if (radar.getLane() == hashMap2.get("雨棚摄像枪-X108")[0] || radar.getLane() == hashMap2.get("雨棚摄像枪-X108")[1]) {
                                Car car = newCar(radar, "12");
                                sendJsonToLocalPort(gson.toJson(car));
                            }
                        }
                        int crc = ByteBuffer.wrap(recv, start, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
                        start += 4;

                        int end = ByteBuffer.wrap(recv, start, 4).order(java.nio.ByteOrder.LITTLE_ENDIAN).getInt();
//                    Thread.sleep(100);
                    } catch (Exception e) {
                        LocalDateTime now = LocalDateTime.now();
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        logger.error(now.format(formatter));
                        logger.error("3.1.2.73,jc14获取数据时出现问题");
                        logger.error("msg", e);
                    }


                }
            }
        });
        thread1_73_2.start(); // 启动线程1_73_2


        try (Connection connection = DriverManager.getConnection(DB_URL, USER, PASSWORD); Statement statement = connection.createStatement()) {
            Class.forName(JDBC_DRIVER);
            String tableName = "t_data_source";
            String query = "SELECT `name` FROM " + tableName + " where device = 4 and is_on_line = 0";
            while (true) {
                ResultSet resultSet = statement.executeQuery(query);
                while (resultSet.next()) {
                    String name = resultSet.getString("name");
                    if (hashMap1.containsKey(name)) {
                        hashSet.add(name);
                    }
                }
                judge(hashMap3, hashSet);
                hashSet.clear();
                try {
                    Thread.sleep(1000);
                } catch (Exception e) {
                    LocalDateTime now = LocalDateTime.now();
                    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                    logger.error(now.format(formatter));
                    logger.error("msg", e);
                }
            }
        } catch (Exception e) {
            LocalDateTime now = LocalDateTime.now();
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            logger.error(now.format(formatter));
            logger.error("msg", e);
        }


    }

    private static HashMap<String, String> getStringStringHashMap() {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("JC-07外侧摄像机2", "3.1.2.61");
        hashMap.put("JC-07内侧摄像机1", "3.1.2.61");
        hashMap.put("JC-05外侧摄像机1", "3.1.2.62");
        hashMap.put("JC-05内侧摄像机2", "3.1.2.62");
        hashMap.put("JC-03太成匝道门架摄像机", "3.1.2.63");
        hashMap.put("JC-08花莞门架摄像机", "3.1.2.64");
        hashMap.put("JC-01门架快车道摄像机1", "3.1.2.65");
        hashMap.put("JC-01门架慢车道摄像机2", "3.1.2.65");
        hashMap.put("JC-06摄像机", "3.1.2.68");
        hashMap.put("雨棚摄像枪-X102前", "3.1.2.69");
        hashMap.put("雨棚摄像枪-X104前", "3.1.2.69");
        hashMap.put("雨棚摄像枪-X106前", "3.1.2.69");
        hashMap.put("雨棚摄像枪-X112", "3.1.2.72");
        hashMap.put("雨棚摄像枪-X114", "3.1.2.72");
        hashMap.put("雨棚摄像枪-X108", "3.1.2.73");
        hashMap.put("雨棚摄像枪-X110", "3.1.2.73");
        return hashMap;
    }

    private static HashMap<String, int[]> getStringIntArrayHashMap() {
        HashMap<String, int[]> hashMap = new HashMap<>();
        hashMap.put("JC-07外侧摄像机2", new int[]{1, 2});
        hashMap.put("JC-07内侧摄像机1", new int[]{3, 4});
        hashMap.put("JC-05外侧摄像机1", new int[]{1, 2});
        hashMap.put("JC-05内侧摄像机2", new int[]{3, 4});
        hashMap.put("JC-03太成匝道门架摄像机", new int[]{1, 2});
        hashMap.put("JC-08花莞门架摄像机", new int[]{1, 2});
        hashMap.put("JC-01门架快车道摄像机1", new int[]{1, 2});
        hashMap.put("JC-01门架慢车道摄像机1", new int[]{3, 4});
        hashMap.put("JC-06摄像机", new int[]{1, 2});
        hashMap.put("雨棚摄像枪-X106前", new int[]{2, 1});
        hashMap.put("雨棚摄像枪-X104前", new int[]{4, 3});
        hashMap.put("雨棚摄像枪-X102前", new int[]{6, 5});
        hashMap.put("雨棚摄像枪-X114", new int[]{2, 1});
        hashMap.put("雨棚摄像枪-X112", new int[]{4, 3});
        hashMap.put("雨棚摄像枪-X110", new int[]{2, 1});
        hashMap.put("雨棚摄像枪-X108", new int[]{4, 3});
        return hashMap;
    }

    private static HashMap<String, Boolean> getStringBooleanHashMap() {
        HashMap<String, Boolean> hashMap = new HashMap<>();
        hashMap.put("JC-07外侧摄像机2", false);
        hashMap.put("JC-07内侧摄像机1", false);
        hashMap.put("JC-05外侧摄像机1", false);
        hashMap.put("JC-05内侧摄像机1", false);
        hashMap.put("JC-03太成匝道门架摄像机", false);
        hashMap.put("JC-08花莞门架摄像机", false);
        hashMap.put("JC-01门架快车道摄像机1", false);
        hashMap.put("JC-01门架慢车道摄像机1", false);
        hashMap.put("JC-06摄像机", false);
        hashMap.put("雨棚摄像枪-X102前", false);
        hashMap.put("雨棚摄像枪-X104前", false);
        hashMap.put("雨棚摄像枪-X106前", false);
        hashMap.put("雨棚摄像枪-X112", false);
        hashMap.put("雨棚摄像枪-X114", false);
        hashMap.put("雨棚摄像枪-X108", false);
        hashMap.put("雨棚摄像枪-X110", false);
        return hashMap;
    }

    private static Car newCar(Radar radar, String devNo) {
        Car car = new Car();
        car.setMsgType(1000);
        car.setDevno(devNo);
        car.setTimestamp(new BigDecimal(radar.getSecond() + "" + radar.getMillisecond()));
        car.setFrame(24051);
        car.getChannelInfo().setChannelId(radar.getLane());
        car.getChannelInfo().setDirection(1);
        car.getChannelInfo().setDriveWay(1);
        car.getChannelInfo().getCarList().setID(radar.getId() + "");
        car.getChannelInfo().getCarList().setLpn("雷达");
        car.getChannelInfo().getCarList().setLpnColor("绿色");
        car.getChannelInfo().getCarList().setColor("黄色");
        car.getChannelInfo().getCarList().setBrand("福特_蒙迪欧_轿车");
        car.getChannelInfo().getCarList().setType("未知");
        car.getChannelInfo().getCarList().setSpeed("100.0");
        car.getChannelInfo().getCarList().setPosX("1438.0");
        car.getChannelInfo().getCarList().setPosY("274.0");
        car.getChannelInfo().getCarList().setLon(radar.getObjectLongitude() + "");
        car.getChannelInfo().getCarList().setLat(radar.getObjectLatitude() + "");
        car.getChannelInfo().getCarList().setPtcHeading((float) 55.7);
        car.getChannelInfo().getCarList().setVehType(2);
        car.getChannelInfo().getCarList().setVehl(0);
        car.getChannelInfo().getCarList().setObjId(radar.getId());
        car.getChannelInfo().getCarList().setGlobalId(radar.getId());
        car.getChannelInfo().getCarList().setCount(24);
        car.getChannelInfo().getCarList().setIsBayonetMatch(0);
        car.getChannelInfo().getCarList().setDifferLon(0);
        car.getChannelInfo().getCarList().setDifferLat(0);
        car.getChannelInfo().getCarList().setAnalogNum(67);
        return car;
    }

    private static void judge(HashMap<String, Boolean> hashMap3, HashSet<String> hashSet) {
        for (Map.Entry<String, Boolean> entry : hashMap3.entrySet()) {
            if (hashSet.contains(entry.getKey())) {
                entry.setValue(false);
            } else {
                entry.setValue(true);
            }
        }
    }


    public static void sendJsonToLocalPort(String json) throws IOException {
        System.out.println(json);
//        writer.write(json + "\n");
        DatagramSocket socket = null;
        try {
            socket = new DatagramSocket();
            byte[] data = json.getBytes();
            DatagramPacket packet = new DatagramPacket(data, data.length, InetAddress.getByName("127.0.0.1"), 60000);
//            System.out.println("向sleepTime端口发送数据");
            DatagramPacket packet2 = new DatagramPacket(data, data.length, InetAddress.getByName("127.0.0.1"), 1600);
//            System.out.println("向1600端口发送数据");
            socket.send(packet);
            socket.send(packet2);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (socket != null && !socket.isClosed()) {
                socket.close();
            }
        }
    }


}
